package com.ruoyi.common.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 备注枚举值：绒面鞋、奢品、皮衣、皮毛一体、四件套、棉被、背包；
 *                      脏尽洗、油渍、发霉、血渍、起毛、破损、染色、开胶、发黄、发白、划痕、棉成块
 */
@Getter
@AllArgsConstructor
public enum RemarkEnum {
    RUBBER_SHOES("RUBBER_SHOES", "绒面鞋"),
    EXTRA_CLOTH("EXTRA_CLOTH", "奢品"),
    LEATHER_COAT("LEATHER_COAT", "皮衣"),
    LEATHER_MATT("LEATHER_MATT", "皮毛一体"),
    FOUR_PIECE("FOUR_PIECE", "四件套"),
    COTTON_BED("COTTON_BED", "棉被"),
    BACKPACK("BACKPACK", "背包"),
    DIRTY_END("DIRTY_END", "脏尽洗"),
    OIL_STAIN("OIL_STAIN", "油渍"),
    FOUL("FOUL", "发霉"),
    BLOOD_STAIN("BLOOD_STAIN", "血渍"),
    GROWTH_STAIN("GROWTH_STAIN", "起毛"),
    BROKEN("BROKEN", "破损"),
    DYE("DYE", "染色"),
    OPEN_GLUE("OPEN_GLUE", "开胶"),
    FADED("FADED", "发黄"),
    WHITE_OUT("WHITE_OUT", "发白"),
    SCRATCH("SCRATCH", "划痕"),
    COTTON_BLOCK("COTTON_BLOCK", "棉成块");
    @EnumValue
    private String code;
    @JsonValue
    private String desc;

    /**
     * 根据code获取枚举值
     * @param code
     * @return
     */
    @JsonCreator
    public static RemarkEnum getByCode(String code) {
        for (RemarkEnum value : values()) {
            if (value.code.equals(code)) {
                return value;
            }
        }
        return null;
    }

    /**
     * 获取枚举值列表
     * @return
     */
    public static List<Map<String,String>> getList(){
        Arrays.stream(values()).map(value -> {
            Map<String,String> map = new HashMap<>();
            map.put("code",value.code);
            map.put("desc",value.desc);
            return map;
        }).collect(Collectors.toList());
        return null;
    }
}
